<?php 
	/**
	 * __set_state魔术方法
	 */
	class Person {
		public $name = "";
		public $age  = 18;
		public $sex  = "男";

		public function __construct($name, $age, $sex) {
			$this->name = $name;
			$this->age  = $age;
			$this->sex  = $sex;
		}

		public function say() {
			echo "我叫".$this->name;
		}

		public function __toString() {
			echo "Hello!!!";
		}

		static function __set_state ($arr) {
			$p = new Person("李四", 22, "女");

			$p->name = $arr['name'];
			$p->age = $arr['age'];
			$p->sex = $arr['sex'];

			return $p;
		}
	}

	$p = new Person("张三", 20, "男");
	$p->name = "李小龙";
	$p->age = 33;
	$p->sex = "男";

	eval('$b = '.var_export($p, true).";");

	echo "<pre>";
	var_dump($b);
	echo "</pre>";




 ?>